﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Supabase.Postgrest.Attributes;
using Supabase.Postgrest.Models;

namespace SimpleTool.Server
{
    [Supabase.Postgrest.Attributes.Table("product_config_field")]
    public sealed class ProductConfigField : BaseModel
    {
        [Supabase.Postgrest.Attributes.Column("code")]
        public string Code { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("field_json")]
        public string FieldJson { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("field_product")]
        public string FieldProduct { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("field_process")]
        public string FieldProcess { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("alter_time")]
        public string AlterTime { set; get; } = DateTime.Now.ToString();
    }

    [Supabase.Postgrest.Attributes.Table("product_config_relation")]
    public sealed class ProductConfigRelation : BaseModel
    {
        [Supabase.Postgrest.Attributes.Column("prd_id"), Supabase.Postgrest.Attributes.PrimaryKey]
        public string PrdId { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("prd_name")]
        public string PrdName { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("prd_process")]
        public string PrdProcess { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("prd_treekey")]
        public int PrdTreeKey { set; get; } = 0;

        [Supabase.Postgrest.Attributes.Column("prd_apply")]
        public int PrdApply { set; get; } = 0;
    }

    [Supabase.Postgrest.Attributes.Table("workorder_unfold")]
    public sealed class WorkOrderUnfold : BaseModel
    {
        [Supabase.Postgrest.Attributes.Column("id")]
        public string Id { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("sn")]
        public string Sn { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("sn_suffix")]
        public string SnSuffix { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("imei"), Supabase.Postgrest.Attributes.PrimaryKey]
        public string Imei { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("imei_suffix")]
        public string ImeiSuffix { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("secret_key")]
        public string SecretKey { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("onenet_product_id")]
        public string OnenetProductId { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("onenet_register_id")]
        public string OnenetRegisterId { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("product_api_key")]
        public string ProductApiKey { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("device_api_key")]
        public string DeviceApiKey { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("blue_mac")]
        public string BlueMac { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("state")]
        public string State { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("product_name")]
        public string ProductName { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("product_type")]
        public string ProductType { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("product_num")]
        public string ProductNum { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("product_version")]
        public string ProductVersion { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("workorder_num")]
        public string WorkorderNum { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("ng")]
        public string Ng { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("ng1")]
        public string Ng1 { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("using_time")]
        public string UsingTime { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("verify_time")]
        public string VerifyTime { get; set; } = string.Empty;

    }

    [Supabase.Postgrest.Attributes.Table("workorder_preview")]
    public sealed class WorkOrderPreview : BaseModel
    {
        [Supabase.Postgrest.Attributes.Column("workorder_num"), Supabase.Postgrest.Attributes.PrimaryKey]
        public string WorkorderNum { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("product_name")]
        public string ProductName { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("product_type")]
        public string ProductType { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("sn_start")]
        public string SnStart { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("sn_end")]
        public string SnEnd { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("imei_start")]
        public string ImeiStart { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("imei_end")]
        public string ImeiEnd { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("version")]
        public string Version { get; set; } = string.Empty;
    }

    [Supabase.Postgrest.Attributes.Table("dbfield_relation")]
    public sealed class DbFieldRelation : BaseModel
    {
        [Supabase.Postgrest.Attributes.Column("prd_name")]
        public string ProductName { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("field_json"), Supabase.Postgrest.Attributes.PrimaryKey]
        public string FieldJson { get; set; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("consult_columns")]
        public string ConsultColumns { get; set; } = string.Empty;
    }

    [Supabase.Postgrest.Attributes.Table("serial_config")]
    public sealed class SerialConfig : BaseModel
    {
        [Supabase.Postgrest.Attributes.Column("port_name")]
        [Supabase.Postgrest.Attributes.PrimaryKey]
        public string Portname { set; get; } = "COM27";

        [Supabase.Postgrest.Attributes.Column("baud_rate")]
        public string Baudrate { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("data_bits")]
        public string Databits { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("stop_bits")]
        public string Stopbits { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("parity_bits")]
        public string Paritybits { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("hand_shake")]
        public string Handshake { set; get; } = string.Empty;

    }

    [Supabase.Postgrest.Attributes.Table("serial_command")]
    public sealed class SerialCommand : BaseModel
    {
        [Supabase.Postgrest.Attributes.Column("command_name"), Supabase.Postgrest.Attributes.PrimaryKey]
        public string Commandname { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("command_alias")]
        public string Commandalias { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("command_interval")]
        public string Commandinterval { set; get; } = string.Empty;
    }

    [Supabase.Postgrest.Attributes.Table("testresult_register")]
    public class TestResultRegister : BaseModel
    {
        [Supabase.Postgrest.Attributes.Column("product")]
        public string Product { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("process")]
        public string Process { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("step")]
        public string Step { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("imei")]
        public string Imei { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("origin")]
        public string Origin { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("result")]
        public bool Result { set; get; } = true;

        [Supabase.Postgrest.Attributes.Column("subjoin")]
        public string Subjoin { set; get; } = string.Empty;

        [Supabase.Postgrest.Attributes.Column("date")]
        public string Date { set; get; } = DateTime.Now.ToString();
    }

    [Supabase.Postgrest.Attributes.Table("testresult_register")]
    public sealed class TestResultRegisterElite : TestResultRegister
    {
        [Supabase.Postgrest.Attributes.Column("id")]
        [Supabase.Postgrest.Attributes.PrimaryKey]
        public long ID { get; set; }
    };
}
